{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<script src="__PUBLIC__/admin/vendor/fuelux/radio.js"></script>
<section class="panel">
    {if isset($info)}
    <header class="panel-heading">
        <h4>编辑会员</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" method="post" onsubmit="return false" role="form">
            <div class="form-group">
                <label class="col-sm-2 control-label">手机号</label>

                <div class="col-sm-5">
                    <input type="text" readonly value="{$info->mobile}" name="mobile" class="form-control"
                           placeholder="请输入手机号">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">会员昵称</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->nick_name}" name="nick_name" class="form-control"
                           placeholder="请输入会员昵称">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">头像<br/>(建议最佳图片显示效果 480*480 )</label>
                <div class="col-sm-5">
                    <div id="fileList" class="uploader-list" style="float:right">
                        <img src="{$info->avatar}">
                        <a class="file-panel" href="javascript:;" onclick="remove(this)">
                            <span class="fa fa-close"></span>
                        </a>
                        <input type="hidden" id="data_avatar" name="photo" value="{$info->avatar}">
                    </div>
                    <div id="imgPicker" style="float:left">添加图片</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">交易密码</label>

                <div class="col-sm-5">
                    <input type="password" name="trad_password" class="form-control" placeholder="交易密码">
                </div>
                <div class="class-sm-5">
                    <span class="help-block">如果不填写就不会修改</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">登录密码</label>

                <div class="col-sm-5">
                    <input type="password" name="password" class="form-control" placeholder="登录密码">
                </div>
                <div class="class-sm-5">
                    <span class="help-block">如果不填写就不会修改</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->wx}" name="wx" class="form-control"
                           placeholder="请输入微信">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信收款码</label>
                <div class="col-sm-5">
                    <div id="filewx" class="uploader-list" style="float:right">
                        <div id="" class="file-item thumbnail draggable-element d-" 0="" style="position:relative;">
                            <img src="{$info->wx_image_url}">
                            <a class="file-panel" href="javascript:;" onclick="remove(this)">
                                <span class="fa fa-close"></span>
                            </a>
                            <input type="hidden" id="data_wx" name="wx_image_url" value="{$info->wx_image_url}">
                        </div>
                    </div>
                    <div id="imgwx" style="float:left">添加图片</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">支付宝</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->zfb}" name="zfb" class="form-control"
                           placeholder="请输入支付宝">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">支付宝收款码</label>
                <div class="col-sm-5">
                    <div id="filezfb" class="uploader-list" style="float:right">
                        <div id="WU_FILE_0" class="file-item thumbnail draggable-element d-" 0="" style="position:relative;">
                            <img src="{$info->zfb_image_url}">
                            <a class="file-panel" href="javascript:;" onclick="remove(this)">
                                <span class="fa fa-close"></span>
                            </a>
                            <input type="hidden" id="data_zfb" name="zfb_image_url" value="{$info->zfb_image_url}">
                        </div>

                    </div>
                    <div id="imgzfb" style="float:left">添加图片</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">开户行名</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->card_name}" name="card_name" class="form-control"
                           placeholder="请输入开户行名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">银行卡号</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->card_number}" name="card_number" class="form-control"
                           placeholder="请输入银行卡号">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">真实姓名</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->real_name}" name="real_name" class="form-control"
                           placeholder="请输入真实姓名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">身份证号</label>

                <div class="col-sm-5">
                    <input type="text" value="{$info->card_id}" name="card_id" class="form-control"
                           placeholder="请输入身份证号">
                </div>
            </div>
             <div class="form-group" style="display: none;">
                <label class="col-sm-2 control-label">会员等级</label>

                <div class="col-sm-5">
                    <select name="level" class="form-control">

                        {foreach $levelcate as $k=>$item}
                        <option {if $info->level == $k}selected{/if} value="{$k}">
                            {$item}
                        </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group" >
                <label class="col-sm-2 control-label">团长等级</label>

                <div class="col-sm-5">
                    <select name="team_level" class="form-control">
                        <option {if $info->team_level ==0}selected{/if} value="0">

                        </option>
                        {foreach $teamlevel as $k=>$item}
                        <option {if $info->team_level == $item['id']}selected{/if} value="{$item['id']}">
                            {$item.name}
                        </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group" >
                <label class="col-sm-2 control-label">代理商等级</label>

                <div class="col-sm-5">
                    <select name="agent_level" class="form-control">
                        <option {if $info->agent_level ==0}selected{/if} value="0">
                            无
                        </option>
                        {foreach $agentlevel as $k=>$item}
                        <option {if $info->agent_level == $item['id']}selected{/if} value="{$item['id']}">
                            {$item.name}
                        </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">代理商到期时间</label>

                <div class="col-sm-5">

                    <input type="text" value="{if $info->agent_over_time}{$info->agent_over_time|date='Y-m-d H:i:s'}{else}{/if}" name="agent_over_time" id="agentTime" class="form-control" placeholder="代理商到期时间">
                </div>
            </div>
            <div class="form-group" >
                <label class="col-sm-2 control-label">房主等级</label>

                <div class="col-sm-5">
                    <select name="house_level" class="form-control">
                        <option {if $info->house_level ==0}selected{/if} value="0">

                        </option>
                        {foreach $houselevel as $k=>$item}
                        <option {if $info->house_level == $item['id']}selected{/if} value="{$item['id']}">
                            {$item.name}
                        </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">房主到期时间</label>

                <div class="col-sm-5">

                    <input type="text" value="{if $info->house_over_time}{$info->house_over_time|date='Y-m-d H:i:s'}{else}{/if}" name="house_over_time" id="houseTime" class="form-control" placeholder="房主到期时间">
                </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-2 control-label">区域代理等级</label>

                <div class="col-sm-5">
                    <select name="area_level" id="area_level" class="form-control" onchange="getValue()">
                        <option {if $info->area_level ==0}selected{/if} value="0">

                        </option>
                        {foreach $arealevel as $k=>$item}
                        <option {if $info->area_level == $item['id']}selected{/if} value="{$item['id']}">
                            {$item.name}
                        </option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <script>
                function getValue() {
                    // 123);
                    // console.log();
                    var val = $('#area_level').val();
                    if(val == 1){
                        $('#city').attr("disabled", false);
                        $('#area').attr("disabled", false);
                    }else if(val == 2){
                        $('#city').attr("disabled", false);
                        $('#area').attr("disabled", true);
                    }else if(val == 3){
                        $('#city').attr("disabled", true);
                        $('#area').attr("disabled", true);
                    }
                }
            </script>
            <div class="form-group">
                <label class="col-sm-2 control-label">省</label>

                <div class="col-sm-5">
                    <select name="province" class="form-control" id="province" onchange="changeCity()">

                        <option selected value="">请选择省份</option>

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">市</label>

                <div class="col-sm-5">
                    <select name="city" {if $info.area_level == 3}disabled{/if} class="form-control" id="city" onchange="changeArea()">

                        <option selected value="">请选择市</option>

                    </select>
                </div>
            </div>
            <div class="form-group" id="area_box" >
                <label class="col-sm-2 control-label">区/县</label>

                <div class="col-sm-5">
                    <select name="area" {if $info.area_level == 2 || $info.area_level == 3}disabled{/if} class="form-control" id="area" >

                        <option selected value="">请选择区/县</option>

                    </select>
                </div>
            </div>
            <script>
                $("#city").arrt()
            </script>
            <div class="form-group">
                <label class="col-sm-2 control-label">区域代理到期时间</label>

                <div class="col-sm-5">

                    <input type="text" value="{if $info->area_over_time}{$info->area_over_time|date='Y-m-d H:i:s'}{else}{/if}" name="area_over_time" id="areaTime" class="form-control" placeholder="区域代理到期时间">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">是否合伙人</label>

                <div class="col-sm-5">

                    <label class="radio radio-custom pull-left">
                        <input type="radio" {if $info->robot == 1}checked{/if} name="partner_level" value="1">
                        <i class="radio "></i> 是
                    </label>
                    <label class="radio radio-custom pull-left">
                        <input type="radio" {if $info->robot == 0}checked{/if} name="partner_level" value="0">
                        <i class="radio "></i> 否
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">合伙人到期时间</label>

                <div class="col-sm-5">

                    <input type="text" value="{if $info->partner_over_time}{$info->partner_over_time|date='Y-m-d H:i:s'}{else}{/if}" name="partner_over_time" id="partnerTime" class="form-control" placeholder="区域代理到期时间">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">用户类型</label>

                <div class="col-sm-5">
                    <label class="radio radio-custom pull-left">
                        <input type="radio" {if $info->robot == 0}checked{/if} name="robot" value="0">
                        <i class="radio "></i> 用户
                    </label>
                    <label class="radio radio-custom pull-left">
                        <input type="radio" {if $info->robot == 1}checked{/if} name="robot" value="1">
                        <i class="radio "></i> 机器人
                    </label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" data-url="{:url('admin/user/update',['id'=>$info->id])}"
                            onclick="main.ajaxPosts(this)" class="btn btn-primary">确定修改
                    </button>
                </div>
            </div>
        </form>
    </div>
    {else /}
    <header class="panel-heading">
        <h4>添加会员</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" method="post" onsubmit="return false" role="form">

            <div class="form-group">
                <label class="col-sm-2 control-label">上级账号</label>

                <div class="col-sm-5">
                    <input type="text" value="" name="p_nick_name" class="form-control"
                           placeholder="请输入上级账号">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">手机号</label>

                <div class="col-sm-5">
                    <input type="text" value="" name="mobile" class="form-control"
                           placeholder="请输入手机号">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">登录密码</label>

                <div class="col-sm-5">
                    <input type="password" name="password" class="form-control" placeholder="登录密码" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">重复登录密码</label>

                <div class="col-sm-5">
                    <input type="password" name="re_password" class="form-control" placeholder="请再次输入登录密码">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">交易密码</label>

                <div class="col-sm-5">
                    <input type="password" name="trad_password" class="form-control" placeholder="交易密码" autocompleted="off" autocomplete="new-password">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">重复支付密码</label>

                <div class="col-sm-5">
                    <input type="password" name="re_trad_password" class="form-control" placeholder="请再次输入支付密码" maxlength="6" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">用户类型</label>

                <div class="col-sm-5">
                    <label class="radio radio-custom pull-left">
                        <input type="radio" checked name="robot" value="0">
                        <i class="radio "></i> 用户
                    </label>
                    <label class="radio radio-custom pull-left">
                        <input type="radio"  name="robot" value="1">
                        <i class="radio "></i> 机器人
                    </label>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" onclick="main.ajaxPosts(this)" data-url="{:url('admin/user/save')}"
                            class="btn btn-primary">提交
                    </button>
                </div>
            </div>

        </form>
    </div>
    {/if}
</section>
{/block}


{block name="footer"}
<script src="__PUBLIC__/admin/js/laydate/laydate.js"></script>
<script src="__PUBLIC__/admin/js/areaList.js"></script>
<script>
    {if isset($info)}
        var this_province = '{$info->province}';
        var this_city = '{$info->city}';
        var this_area = '{$info->area}';
    {else}
        var this_province = '';
        var this_city = '';
        var this_area = '';
    {/if}
        var this_province_id = this_city_id = this_area_id = 0;
        for(var i in jsons.province_list){
            if(this_province == jsons.province_list[i]){
                this_province_id = i;
            }
        }
        for(var i in jsons.city_list){
            if(this_city == jsons.city_list[i]){
                this_city_id = i;
            }
        }
        for(var i in jsons.county_list){
            if(this_area == jsons.county_list[i]){
                this_area_id = i;
            }
        }


        var province = '';
        var city = '';
        var area = '';
    for(var i in jsons.province_list){
        if(this_province_id==i){
            province += `<option selected value="`+jsons.province_list[i]+`" data_id="`+i+`">`+jsons.province_list[i]+`</option>`;
        }else{
            province += `<option value="`+jsons.province_list[i]+`" data_id="`+i+`">`+jsons.province_list[i]+`</option>`;
        }

        for(var i in jsons.city_list){
            if(this_province_id ==0){
                //
            }else{
                if(this_province_id.substring(0,2) == i.substring(0,2)) {
                    if (this_city_id == i) {
                        city += `<option selected value="` + jsons.city_list[i] + `" data_id="` + i + `">` + jsons.city_list[i] + `</option>`;
                    }else{
                        city += `<option value="` + jsons.city_list[i] + `" data_id="` + i + `">` + jsons.city_list[i] + `</option>`;
                    }
                }
            }
        }
        $('#city').html(city);

        for(var i in jsons.county_list){
            if(this_city_id ==0){
                //
            }else{
                if(this_city_id.substring(0,4) == i.substring(0,4)){
                    if(this_area_id==i){
                        area += `<option selected value="`+jsons.county_list[i]+`" data_id="`+i+`">`+jsons.county_list[i]+`</option>`;
                    }else{
                        area += `<option value="`+jsons.county_list[i]+`" data_id="`+i+`">`+jsons.county_list[i]+`</option>`;
                    }
                }
            }
        }
        $('#area').html(area);
    }

    $('#province').append(province);


    function changeCity(){
        city = '<option selected value="">请选择市</option>';
        var province_id = $('#province').find("option:checked").attr('data_id').substring(0,2);

        for(var i in jsons.city_list){
            if(province_id == i.substring(0,2)){

                if(this_city_id==i){
                    city += `<option selected value="`+jsons.city_list[i]+`" data_id="`+i+`">`+jsons.city_list[i]+`</option>`;
                }else{
                    city += `<option value="`+jsons.city_list[i]+`" data_id="`+i+`">`+jsons.city_list[i]+`</option>`;
                }
            }
        }
        $('#city').html(city);
    }
    function changeArea(){
        area = '<option selected value="">请选择市</option>';
        var city_id = $('#city').find("option:checked").attr('data_id').substring(0,4);

        for(var i in jsons.county_list){
            if(city_id == i.substring(0,4)){
                if(this_area_id==i){
                    area += `<option selected value="`+jsons.county_list[i]+`" data_id="`+i+`">`+jsons.county_list[i]+`</option>`;
                }else{
                    area += `<option value="`+jsons.county_list[i]+`" data_id="`+i+`">`+jsons.county_list[i]+`</option>`;
                }

            }

        }
        $('#area').html(area);
    }


    laydate.render({
        elem: '#startTime',
        type: 'datetime'
    });
    laydate.render({
        elem: '#agentTime',
        type: 'datetime'
    });
    laydate.render({
        elem: '#houseTime',
        type: 'datetime'
    });
    laydate.render({
        elem: '#areaTime',
        type: 'datetime'
    });
    laydate.render({
        elem: '#partnerTime',
        type: 'datetime'
    });

    laydate.render({
        elem: '#endTime',
        type: 'datetime'
    });
</script>
<script src="__PUBLIC__/admin/vendor/fuelux/checkbox.js"></script>
<link rel="stylesheet" href="__PUBLIC__/static/webuploader/webuploader.css">
<script type="text/javascript" src='__PUBLIC__/static/webuploader/webuploader.js'></script>
<script>
    var $list = $('#fileList');
    var uploader = WebUploader.create({
        auto: true,// 选完文件后，是否自动上传。
        swf: '/static/webuploader/Uploader.swf',// swf文件路径 换成你的接收路径
        server: "{:url('upload/uploadImg')}",// 文件接收服务端 换成你的接收路径
        duplicate :false,// 重复上传图片，true为可重复false为不可重复
        pick: {id:'#imgPicker',multiple:false},// 选择文件的按钮
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },

        'onUploadSuccess': function(file, data, response) {
            var up_src = data._raw.replace("\\", "\/");
            var ph_src = JSON.parse(up_src);
            ph_src = ph_src.data[0].replace("\/\/", "\/");
            ph_src = ph_src.replace("\\", "\/");

            //上传成功后显示图片
            var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail draggable-element d-"'+file.id.substr(file.id.length-1,1)+' style="position:relative;">' +
                '<img>' +
                '<a class="file-panel" href="javascript:;" onclick="remove(this)">' +
                '<span class="fa fa-close"></span>' +
                '</a>' +
                '<input type="hidden" id="data_photo" name="photo" value="'+ph_src+'">' +
                '</div>'
                ),
                $img = $li.find('img');

            // $list为容器jQuery实例
            $list.html( $li );

            // 创建缩略图 如果为非图片文件，可以不用调用此方法 100（宽） x 100（高）
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                $img.attr( 'src', src );
            }, 100, 100 );
        }
    });
    var $list2 = $('#filezfb');
    var uploader = WebUploader.create({
        auto: true,// 选完文件后，是否自动上传。
        swf: '/static/webuploader/Uploader.swf',// swf文件路径 换成你的接收路径
        server: "{:url('upload/uploadImg')}",// 文件接收服务端 换成你的接收路径
        duplicate :false,// 重复上传图片，true为可重复false为不可重复
        pick: {id:'#imgzfb',multiple:false},// 选择文件的按钮
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },

        'onUploadSuccess': function(file, data, response) {
            var up_src = data._raw.replace("\\", "\/");
            var ph_src = JSON.parse(up_src);
            ph_src = ph_src.data[0].replace("\/\/", "\/");
            ph_src = ph_src.replace("\\", "\/");

            //上传成功后显示图片
            var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail draggable-element d-"'+file.id.substr(file.id.length-1,1)+' style="position:relative;">' +
                '<img>' +
                '<a class="file-panel" href="javascript:;" onclick="remove(this)">' +
                '<span class="fa fa-close"></span>' +
                '</a>' +
                '<input type="hidden" id="data_zfb" name="zfb_image_url" value="'+ph_src+'">' +
                '</div>'
                ),
                $img = $li.find('img');

            // $list为容器jQuery实例
            $list2.html( $li );

            // 创建缩略图 如果为非图片文件，可以不用调用此方法 100（宽） x 100（高）
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                $img.attr( 'src', src );
            }, 100, 100 );
        }
    });

    var $list3 = $('#filewx');
    var uploader = WebUploader.create({
        auto: true,// 选完文件后，是否自动上传。
        swf: '/static/webuploader/Uploader.swf',// swf文件路径 换成你的接收路径
        server: "{:url('upload/uploadImg')}",// 文件接收服务端 换成你的接收路径
        duplicate :false,// 重复上传图片，true为可重复false为不可重复
        pick: {id:'#imgwx',multiple:false},// 选择文件的按钮
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },

        'onUploadSuccess': function(file, data, response) {
            var up_src = data._raw.replace("\\", "\/");
            var ph_src = JSON.parse(up_src);
            ph_src = ph_src.data[0].replace("\/\/", "\/");
            ph_src = ph_src.replace("\\", "\/");

            //上传成功后显示图片
            var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail draggable-element d-"'+file.id.substr(file.id.length-1,1)+' style="position:relative;">' +
                '<img>' +
                '<a class="file-panel" href="javascript:;" onclick="remove(this)">' +
                '<span class="fa fa-close"></span>' +
                '</a>' +
                '<input type="hidden" id="data_zfb" name="wx_image_url" value="'+ph_src+'">' +
                '</div>'
                ),
                $img = $li.find('img');

            // $list为容器jQuery实例
            $list3.html( $li );

            // 创建缩略图 如果为非图片文件，可以不用调用此方法 100（宽） x 100（高）
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                $img.attr( 'src', src );
            }, 100, 100 );
        }
    });


    // 当有文件添加进来的时候
    uploader.on( 'fileQueued', function( file ) {

    });

    // 文件上传成功
    uploader.on( 'uploadSuccess', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传成功！');
    });

    // 文件上传失败，显示上传出错。
    uploader.on( 'uploadError', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传出错!');
    });

    /**
     * [remove 移除图片]
     * @post  [file]  [文件名 （必填）]
     * @post  [obj]  [操作对象] [前台操作数据 移除dom标志]
     *
     * @return
     * @Author[summer 1012684399@qq.com] THINK MORE DO LESS
     */
    function remove(obj){
        // console.log(12);

        $(obj).parent('div').remove();
        var html = '<input type="hidden" id="data_photo" name="remove[]" value="">';
        $('#fileList').append(html);
    }
</script>
{/block}



[uid] => 215780
[uid] => 215782
[uid] => 215783
[uid] => 215784
[uid] => 215785
[uid] => 215786
[uid] => 215792
[uid] => 215793
